package com.sgzn.sgpay.service.impl;

import com.sgzn.sgpay.enums.SgsResponseCode;
import com.sgzn.sgpay.model.request.SgsDepositQueryPageRequest;
import com.sgzn.sgpay.model.request.SgsMainOrderQueryPageRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.model.response.result.MainOrderQueryPageResult;
import com.sgzn.sgpay.service.SgsDepositQueryService;
import com.sgzn.sgpay.service.converter.AssembleSgsCommonHandle;
import com.sgzn.sgpay.service.support.SgsResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 充值记录查询服务接口实现类
 * @author huangsenguang
 * @version Id: SgsDepositQueryServiceImpl.java, v 0.1 2018/5/6 13:46 huangsenguang Exp $$
 */
@Slf4j
@Service
public class SgsDepositQueryServiceImpl implements SgsDepositQueryService {

    @Autowired
    private SgsMainOrderServiceImpl sgsMainOrderServiceImpl;


    @Autowired
    private AssembleSgsCommonHandle assembleSgsCommonHandle;

    @Override
    public SgsResultResponse<MainOrderQueryPageResult> queryPage(SgsDepositQueryPageRequest request) {
        try {
            SgsMainOrderQueryPageRequest target = new SgsMainOrderQueryPageRequest();
            target.setPageQueryParam(request.getPageQueryParam());
            assembleSgsCommonHandle.assemble(request, target);
            target.setUserId(request.getUserId());
            target.setOrderType(request.getOrderType());
            return this.sgsMainOrderServiceImpl.queryPage(target);
        } catch (Exception e) {
            log.error("充值记录查询服务: ", e);
        }
        return SgsResponseUtil.INSTANCE.fail(SgsResponseCode.C503.getResponseCode(),SgsResponseCode.C503.getResponseDesc());
    }
}

